﻿CREATE TABLE Currencies
(
	Id int PRIMARY KEY NOT NULL,
	Code varchar(3) NOT NULL,
	Name varchar(MAX) NOT NULL
);
CREATE TABLE Countries
(
	Id int PRIMARY KEY NOT NULL,
	Name varchar(64) NOT NULL,
	/* Foreign keys */
	CurrencyId int NOT NULL REFERENCES Currencies(Id)
);
CREATE TABLE UserProfiles
(
	Id int IDENTITY PRIMARY KEY NOT NULL,
	Name varchar(64) NOT NULL,
	Login varchar(64) UNIQUE NOT NULL,
	Password varchar(64) NOT NULL,
	/* Foreign keys */
	CountryId int REFERENCES Countries(Id)
);
CREATE TABLE Quotes
(
	Id int IDENTITY PRIMARY KEY NOT NULL,
	Ticket varchar(64) NOT NULL,
	Price float NOT NULL,
	Time datetime NOT NULL
);
CREATE TABLE Forecasts
(
	Id int IDENTITY PRIMARY KEY NOT NULL,
	CreationTime datetime NOT NULL,
	PredictionTime datetime NOT NULL,
	MinPredictionPrice float NOT NULL,
	MaxPredictionPrice float NOT NULL,
	/* Foreign keys */
	UserProfileId int NOT NULL REFERENCES UserProfiles(Id)
);